package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "opportunity_", schema = "crm")
public class Opportunity {
    private int oppId;
    private String oppTheme;//机会主题
    private Date oppUpdateDate;//更新日期
    private Integer oppStatus;//状态
    private Integer oppClassify;//分类
    private Date oppFindDate;//发现日期
    private Integer oppSource;//来源
    private String oppOffer;//提供人
    private String oppNeed;//需求
    private Date oppSignDate;//预计签单日期
    private Integer oppPossibility;//可能性
    private BigDecimal oppExpectSum;//预期金额
    private Integer oppPriority;//优先
    private Integer oppStage;//阶段
    private String oppPriRemark;//阶段备注
    private String oppContactName;//联系人
    private Employee employeeByEmpId;//员工
    private Customer customerByCustomerId;//客户
    private List<Action> actionsByOppId;//行动历史
    private List<Task> tasksByOppId;//待办任务
    private List<Tracelog> tracelogsByOppId;//机会跟踪
    private List<Quotation> quotationsByOppId;//报价
    private List<Businesstrip> businesstripsByOppId;//出差
    private List<Solution> solutionsByOppId;//解决方案
    private List<Demand> demandsByOppId;//详细需求
    private List<Competitor> competitorsByOppId;//竞争

    @Id
    @Column(name = "opp_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getOppId() {
        return oppId;
    }

    public void setOppId(int oppId) {
        this.oppId = oppId;
    }


    @Basic
    @Column(name = "opp_theme", nullable = true, length = 255)
    public String getOppTheme() {
        return oppTheme;
    }

    public void setOppTheme(String oppTheme) {
        this.oppTheme = oppTheme;
    }

    @Basic
    @Column(name = "opp_update_date", nullable = true)
    public Date getOppUpdateDate() {
        return oppUpdateDate;
    }

    public void setOppUpdateDate(Date oppUpdateDate) {
        this.oppUpdateDate = oppUpdateDate;
    }

    @Basic
    @Column(name = "opp_status", nullable = true)
    public Integer getOppStatus() {
        return oppStatus;
    }

    public void setOppStatus(Integer oppStatus) {
        this.oppStatus = oppStatus;
    }

    @Basic
    @Column(name = "opp_classify", nullable = true)
    public Integer getOppClassify() {
        return oppClassify;
    }

    public void setOppClassify(Integer oppClassify) {
        this.oppClassify = oppClassify;
    }

    @Basic
    @Column(name = "opp_find_date", nullable = true)
    public Date getOppFindDate() {
        return oppFindDate;
    }

    public void setOppFindDate(Date oppFindDate) {
        this.oppFindDate = oppFindDate;
    }

    @Basic
    @Column(name = "opp_source", nullable = true)
    public Integer getOppSource() {
        return oppSource;
    }

    public void setOppSource(Integer oppSource) {
        this.oppSource = oppSource;
    }

    @Basic
    @Column(name = "opp_offer", nullable = true, length = 255)
    public String getOppOffer() {
        return oppOffer;
    }

    public void setOppOffer(String oppOffer) {
        this.oppOffer = oppOffer;
    }

    @Basic
    @Column(name = "opp_need", nullable = true, length = 255)
    public String getOppNeed() {
        return oppNeed;
    }

    public void setOppNeed(String oppNeed) {
        this.oppNeed = oppNeed;
    }

    @Basic
    @Column(name = "opp_sign_date", nullable = true)
    public Date getOppSignDate() {
        return oppSignDate;
    }

    public void setOppSignDate(Date oppSignDate) {
        this.oppSignDate = oppSignDate;
    }

    @Basic
    @Column(name = "opp_possibility", nullable = true)
    public Integer getOppPossibility() {
        return oppPossibility;
    }

    public void setOppPossibility(Integer oppPossibility) {
        this.oppPossibility = oppPossibility;
    }

    @Basic
    @Column(name = "opp_expect_sum", nullable = true, precision = 5)
    public BigDecimal getOppExpectSum() {
        return oppExpectSum;
    }

    public void setOppExpectSum(BigDecimal oppExpectSum) {
        this.oppExpectSum = oppExpectSum;
    }

    @Basic
    @Column(name = "opp_priority", nullable = true)
    public Integer getOppPriority() {
        return oppPriority;
    }

    public void setOppPriority(Integer oppPriority) {
        this.oppPriority = oppPriority;
    }

    @Basic
    @Column(name = "opp_stage", nullable = true)
    public Integer getOppStage() {
        return oppStage;
    }

    public void setOppStage(Integer oppStage) {
        this.oppStage = oppStage;
    }

    @Basic
    @Column(name = "opp_pri_remark", nullable = true, length = 255)
    public String getOppPriRemark() {
        return oppPriRemark;
    }

    public void setOppPriRemark(String oppPriRemark) {
        this.oppPriRemark = oppPriRemark;
    }

    @Basic
    @Column(name = "opp_contact_name", nullable = true, length = 255)
    public String getOppContactName() {
        return oppContactName;
    }

    public void setOppContactName(String oppContactName) {
        this.oppContactName = oppContactName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Opportunity that = (Opportunity) o;
        return oppId == that.oppId &&
                Objects.equals(oppTheme, that.oppTheme) &&
                Objects.equals(oppUpdateDate, that.oppUpdateDate) &&
                Objects.equals(oppStatus, that.oppStatus) &&
                Objects.equals(oppClassify, that.oppClassify) &&
                Objects.equals(oppFindDate, that.oppFindDate) &&
                Objects.equals(oppSource, that.oppSource) &&
                Objects.equals(oppOffer, that.oppOffer) &&
                Objects.equals(oppNeed, that.oppNeed) &&
                Objects.equals(oppSignDate, that.oppSignDate) &&
                Objects.equals(oppPossibility, that.oppPossibility) &&
                Objects.equals(oppExpectSum, that.oppExpectSum) &&
                Objects.equals(oppPriority, that.oppPriority) &&
                Objects.equals(oppStage, that.oppStage) &&
                Objects.equals(oppPriRemark, that.oppPriRemark) &&
                Objects.equals(oppContactName, that.oppContactName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(oppId, oppTheme, oppUpdateDate, oppStatus, oppClassify, oppFindDate, oppSource, oppOffer, oppNeed, oppSignDate, oppPossibility, oppExpectSum, oppPriority, oppStage, oppPriRemark, oppContactName);
    }

    @ManyToOne
    @JoinColumn(name = "emp_id", referencedColumnName = "emp_id")
    public Employee getEmployeeByEmpId() {
        return employeeByEmpId;
    }

    public void setEmployeeByEmpId(Employee employeeByEmpId) {
        this.employeeByEmpId = employeeByEmpId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Action> getAction() {
        return actionsByOppId;
    }

    public void setAction(List<Action> actionsByOppId) {
        this.actionsByOppId = actionsByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Tracelog> getTracelog() {
        return tracelogsByOppId;
    }

    public void setTracelog(List<Tracelog> tracelogsByOppId) {
        this.tracelogsByOppId = tracelogsByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Quotation> getQuotation() {
        return quotationsByOppId;
    }

    public void setQuotation(List<Quotation> quotationsByOppId) {
        this.quotationsByOppId = quotationsByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Businesstrip> getBusinesstrip() {
        return businesstripsByOppId;
    }

    public void setBusinesstrip(List<Businesstrip> businesstripsByOppId) {
        this.businesstripsByOppId = businesstripsByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Solution> getSolution() {
        return solutionsByOppId;
    }

    public void setSolution(List<Solution> solutionsByOppId) {
        this.solutionsByOppId = solutionsByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Demand> getDemand() {
        return demandsByOppId;
    }

    public void setDemand(List<Demand> demandsByOppId) {
        this.demandsByOppId = demandsByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Task> getTask() {
        return tasksByOppId;
    }

    public void setTask(List<Task> tasksByOppId) {
        this.tasksByOppId = tasksByOppId;
    }

    @OneToMany(mappedBy = "opportunityByOppId",cascade={CascadeType.PERSIST,CascadeType.REMOVE})
    public List<Competitor> getCompetitor() {
        return competitorsByOppId;
    }

    public void setCompetitor(List<Competitor> competitorsByOppId) {
        this.competitorsByOppId = competitorsByOppId;
    }

    @Override
    public String toString() {
        return "Opportunity{" +
                "oppId=" + oppId +
                ", oppTheme='" + oppTheme + '\'' +
                ", oppUpdateDate=" + oppUpdateDate +
                ", oppStatus=" + oppStatus +
                ", oppClassify=" + oppClassify +
                ", oppFindDate=" + oppFindDate +
                ", oppSource=" + oppSource +
                ", oppOffer='" + oppOffer + '\'' +
                ", oppNeed='" + oppNeed + '\'' +
                ", oppSignDate=" + oppSignDate +
                ", oppPossibility=" + oppPossibility +
                ", oppExpectSum=" + oppExpectSum +
                ", oppPriority=" + oppPriority +
                ", oppStage=" + oppStage +
                ", oppPriRemark='" + oppPriRemark + '\'' +
                ", oppContactName='" + oppContactName + '\'' +
                ", employeeByEmpId=" + employeeByEmpId +
                ", customerByCustomerId=" + customerByCustomerId +
                '}';
    }
}
